package com.neusoft.chenhanhua.d0912;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;

import javax.swing.JPanel;

public class GamePanel extends JPanel{
	@Override//注解，表示该方法是一个重写方法，不是方法重写不可以加
	public void paint(Graphics g) {
		/*	Graphics：画笔
		 * 		JPanel：类似于画布
		 * 		g.drawImage(img, x, y, observer)
		 * 			img：是一Image对象，即图片对象
		 * 			x：坐标x
		 * 			y：坐标y
		 * 			observer：观察者，暂时不用管，直接写this
		 * 		g.drawImage(img, x, y, width, height, observer);
		 * 			width：指定要画的图片宽度
		 * 			height：高度
		 * 
		 */
//		int x=10;
//		int y =10;
//		int size=30;
//		int path=40;
		String[] names= {"che","ma","xiang","shi","boss","shi","xiang","ma","che","pao","pao","bing","bing","bing","bing","bing"};
        int [] xs= {1,2,3,4,5,6,7,8,9,2,8,1,3,5,7,9};
        int [] ys= {1,1,1,1,1,1,1,1,1,3,3,4,4,4,4,4};
		//		String[] name1= {"","pao","","","","","","pao",""};
//		String[] name2= {"bing","","bing","","bing","","bing","","bing"};
//		int zhenying=0;
		//根据路径获取图片对象
		Image bg = Toolkit.getDefaultToolkit().getImage("pic/qipan.jpg");
		g.drawImage(bg, 0, 0, this);
//		Image che0 = Toolkit.getDefaultToolkit().getImage("pic/che0.png");
//		g.drawImage(che0, 0, 0, 30, 30, this);
//		Image che1 = Toolkit.getDefaultToolkit().getImage("pic/che1.png");
//		g.drawImage(che1, 5, 50, 30, 30, this);
//		Image che2 = Toolkit.getDefaultToolkit().getImage("pic/che0.png");
//		g.drawImage(che2, 50, 0, 30, 30, this);
//		for (int i = 0; i <2; i++) {
//			if (i==1) {
//				i=9;
//				zhenying=1;
//			}
//			
//			for (int j = 0; j < name.length; j++) {
//				
//				Image img = Toolkit.getDefaultToolkit().getImage("pic/"+name[j]+zhenying+".png");
//				g.drawImage(img, x+path*j, y+path*i, size, size, this);
//			}
//		}
//		 zhenying=0;
//		for (int i = 0; i <2; i++) {
//			if (i==1) {
//				i=5;
//				zhenying=1;
//			}
//			
//			for (int j = 0; j < name1.length; j++) {
//				
//				Image img = Toolkit.getDefaultToolkit().getImage("pic/"+name1[j]+zhenying+".png");
//				g.drawImage(img, x+path*j, y+path*i+80, size, size, this);
//			}
//		}
//		zhenying=0;
//		for (int i = 0; i <2; i++) {
//			if (i==1) {
//				i=3;
//				zhenying=1;
//			}
//			
//			for (int j = 0; j < name2.length; j++) {
//				
//				Image img = Toolkit.getDefaultToolkit().getImage("pic/"+name2[j]+zhenying+".png");
//				g.drawImage(img, x+path*j, y+path*i+120, size, size, this);
//			}
//		}

		for(int i = 0; i < names.length; i++) {
			Chess c = new Chess(names[i], new Point(xs[i], ys[i]), 0);
			c.draw(g, this);
		}
		for(int i = 0; i < names.length; i++) {
			Chess c = new Chess(names[i], new Point(xs[i], ys[i]), 1);
			c.reserve();
			c.draw(g, this);
		}
		
	}

}
